package com.truckdispatching.http.controller;

import java.util.HashMap;

import com.truckdispatching.UserManager;
import com.truckdispatching.http.util.TDHttpController;
import com.truckdispatching.util.CarTypeUtil;
import com.truckdispatching.util.ProvinceCityUtil;
import com.truckdispatching.util.TruckLengthUtil;

/**
 * 更改资料
 * 
 * @author harry
 * 
 */
public class UpdateUserInfoHttpController extends TDHttpController {

	@Override
	public String getRequestUrl() {
		return mHostUrl + "/wap/updateUserInfo.do?";
	}

	/**
	 * 
	 * @param username
	 *            姓名
	 * @param mobile
	 *            手机号
	 * @param carNo
	 *            车牌号
	 * @param carLength
	 *            车长
	 * @param target1
	 *            长跑方向1
	 * @param target2
	 *            长跑方向2
	 * @param target3
	 *            长跑方向3
	 */
	public void sendRequest(String username, String mobile, String mobile2, String idCard, String carNo, String carLength, String carType,
			String target1, String target2, String target3) {
		HashMap<String, String> params = new HashMap<String, String>();
		params.put("memberBO.USRREALNAME", username);
		params.put("memberBO.USRMOBILE", mobile);
		params.put("mobile1", mobile2);
		params.put("memberBO.USRIDNO", idCard);
		params.put("TKPLATENO", carNo);
		params.put("DCT_TKLEN", TruckLengthUtil.getTruckLengthCode(carLength));
		params.put("DCT_TT", CarTypeUtil.getTypeCode(carType));
		params.put("TKTarget1", ProvinceCityUtil.getCodeByPcName(target1));
		params.put("TKTarget2", ProvinceCityUtil.getCodeByPcName(target2));
		params.put("TKTarget3", ProvinceCityUtil.getCodeByPcName(target3));
		params.put("jsessionid", UserManager.getToken());
		sendRequest(params, true);
	}

	@Override
	public void onSuccess(String response) {
		callOnResponseListener(null);
	}

	@Override
	public void onError(int errorCode, String errorMessage) {
		callOnResponseErrorListener(errorCode, errorMessage);
	}

}
